package org.jeecg.modules.wangyue.controller.sys;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.wangyue.constant.*;
import org.jeecg.modules.wangyue.entity.Configuration;
import org.jeecg.modules.wangyue.entity.WithdrawalReview;
import org.jeecg.modules.wangyue.model.req.ReqCommonModel;
import org.jeecg.modules.wangyue.service.IConfigurationService;
import org.jeecg.modules.wangyue.service.IWithdrawalReviewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.Date;
import java.util.List;

/**
* @Description: 提现审核管理
* @Author: jeecg-boot
* @Date:   2023-06-30
* @Version: V1.0
*/
@Slf4j
@Api(tags="提现审核管理")
@RestController
@RequestMapping("/wangyue/sys/withdrawalReview")
public class WithdrawalReviewManageController extends JeecgController<WithdrawalReview, IWithdrawalReviewService> {
   @Autowired
   private IWithdrawalReviewService withdrawalReviewService;


    /**
     * 提现审核管理-分页列表查询
     *
     * @param keywords      关键字
     * @param reviewStatus  审核状态(0-待审核,1-审核通过,2-驳回)
     * @param pageNo        第几页
     * @param pageSize      每页大小
     * @return
     */
    @AutoLog(value = "提现审核管理-分页列表查询")
    @ApiOperation(value="提现审核管理-分页列表查询", notes="提现审核管理-分页列表查询")
    @GetMapping(value = "/list")
    public Result<?> queryPageList(@RequestParam(name="keywords", required = false) String keywords,
                                   @RequestParam(name="reviewStatus", required = false) String reviewStatus,
                                   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
        QueryWrapper<WithdrawalReview> queryWrapper = new QueryWrapper<>();
        if(oConvertUtils.isNotEmpty(keywords)){
            queryWrapper.like("real_name", keywords);
        }
        if (oConvertUtils.isNotEmpty(reviewStatus)){
            queryWrapper.eq("review_status", reviewStatus);
        }
        queryWrapper.eq("del_flag", DelFlagConstant.normal);
        queryWrapper.orderByAsc("review_status").orderByDesc("create_time");
        Page<WithdrawalReview> page = new Page<WithdrawalReview>(pageNo, pageSize);
        IPage<WithdrawalReview> pageList = withdrawalReviewService.page(page, queryWrapper);
        return Result.OK(pageList);
    }


    /**
     * 提现审核管理-技师提现驳回
     *
     * @param reqCommonModel
     * @return
     */
    @AutoLog(value = "提现审核管理-技师提现驳回")
    @ApiOperation(value="提现审核管理-技师提现驳回", notes="提现审核管理-技师提现驳回")
    @PostMapping(value = "/jsWithdrawalReject")
    public Result<?> jsWithdrawalReject(@Valid @RequestBody ReqCommonModel reqCommonModel){
        return withdrawalReviewService.jsWithdrawalReject(reqCommonModel.getId());
    }


    /**
     * 提现审核管理-技师提现审核通过
     *
     * @param reqCommonModel
     * @return
     */
    @AutoLog(value = "提现审核管理-技师提现审核通过")
    @ApiOperation(value="提现审核管理-技师提现审核通过", notes="提现审核管理-技师提现审核通过")
    @PostMapping(value = "/jsWithdrawalPass")
    public Result<?> jsWithdrawalPass(@Valid @RequestBody ReqCommonModel reqCommonModel){
        return withdrawalReviewService.jsWithdrawalPass(reqCommonModel.getId());
    }



}
